
package org.bridgen.lang.semantics.ast;
import java.util.*;



public class RecoverDecl extends Element implements Cloneable {
    public void flushCache() {
        super.flushCache();
    }
     @SuppressWarnings({"unchecked", "cast"})  public RecoverDecl clone() throws CloneNotSupportedException {
        RecoverDecl node = (RecoverDecl)super.clone();
        node.in$Circle(false);
        node.is$Final(false);
    return node;
    }
     @SuppressWarnings({"unchecked", "cast"})  public RecoverDecl copy() {
      try {
          RecoverDecl node = (RecoverDecl)clone();
          if(children != null) node.children = (ASTNode[])children.clone();
          return node;
      } catch (CloneNotSupportedException e) {
      }
      System.err.println("Error: Could not clone node of type " + getClass().getName() + "!");
      return null;
    }
     @SuppressWarnings({"unchecked", "cast"})  public RecoverDecl fullCopy() {
        RecoverDecl res = (RecoverDecl)copy();
        for(int i = 0; i < getNumChildNoTransform(); i++) {
          ASTNode node = getChildNoTransform(i);
          if(node != null) node = node.fullCopy();
          res.setChild(node, i);
        }
        return res;
    }
    // Declared in PrettyPrint.jrag at line 156

    
    public void pp(StringBuffer buf) {
    	buf.append(indent() + "recover ");
    	getNodeUse().pp(buf);
    	buf.append("\n");
    	for (int i = 0; i < getNumAltRecover(); i++) {
    		getAltRecover(i).pp(buf);
    	}
    }

    // Declared in TypeCodeGen.jrag at line 571

	
	public void generateMethod_possibleSite(String indent, StringBuffer buf) {
		for (int i = 0; i < getNumAltRecover(); i++) {
			AltRecover alt = getAltRecover(i);
			alt.generateMethod_possibleSite(indent, buf);
		}
		buf.append(indent + "return false;\n");
	}

    // Declared in bridgit.ast at line 3
    // Declared in bridgit.ast line 42

    public RecoverDecl() {
        super();

        setChild(new List(), 1);

    }

    // Declared in bridgit.ast at line 11


    // Declared in bridgit.ast line 42
    public RecoverDecl(NodeUse p0, List<AltRecover> p1) {
        setChild(p0, 0);
        setChild(p1, 1);
    }

    // Declared in bridgit.ast at line 16


  protected int numChildren() {
    return 2;
  }

    // Declared in bridgit.ast at line 19

  public boolean mayHaveRewrite() { return false; }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 42
    public void setNodeUse(NodeUse node) {
        setChild(node, 0);
    }

    // Declared in bridgit.ast at line 5

    public NodeUse getNodeUse() {
        return (NodeUse)getChild(0);
    }

    // Declared in bridgit.ast at line 9


    public NodeUse getNodeUseNoTransform() {
        return (NodeUse)getChildNoTransform(0);
    }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 42
    public void setAltRecoverList(List<AltRecover> list) {
        setChild(list, 1);
    }

    // Declared in bridgit.ast at line 6


    private int getNumAltRecover = 0;

    // Declared in bridgit.ast at line 7

    public int getNumAltRecover() {
        return getAltRecoverList().getNumChild();
    }

    // Declared in bridgit.ast at line 11


     @SuppressWarnings({"unchecked", "cast"})  public AltRecover getAltRecover(int i) {
        return (AltRecover)getAltRecoverList().getChild(i);
    }

    // Declared in bridgit.ast at line 15


    public void addAltRecover(AltRecover node) {
        List<AltRecover> list = getAltRecoverList();
        list.addChild(node);
    }

    // Declared in bridgit.ast at line 20


    public void setAltRecover(AltRecover node, int i) {
        List<AltRecover> list = getAltRecoverList();
        list.setChild(node, i);
    }

    // Declared in bridgit.ast at line 24

    public List<AltRecover> getAltRecovers() {
        return getAltRecoverList();
    }

    // Declared in bridgit.ast at line 27

    public List<AltRecover> getAltRecoversNoTransform() {
        return getAltRecoverListNoTransform();
    }

    // Declared in bridgit.ast at line 31


     @SuppressWarnings({"unchecked", "cast"})  public List<AltRecover> getAltRecoverList() {
        return (List<AltRecover>)getChild(1);
    }

    // Declared in bridgit.ast at line 35


     @SuppressWarnings({"unchecked", "cast"})  public List<AltRecover> getAltRecoverListNoTransform() {
        return (List<AltRecover>)getChildNoTransform(1);
    }

    // Declared in NameAnalysis.jrag at line 101
 @SuppressWarnings({"unchecked", "cast"})     public boolean isRecoverDecl() {
        boolean isRecoverDecl_value = isRecoverDecl_compute();
        return isRecoverDecl_value;
    }

    private boolean isRecoverDecl_compute() {  return true;  }

    // Declared in NameAnalysis.jrag at line 198
 @SuppressWarnings({"unchecked", "cast"})     public NodeUse lookupVariable(String name) {
        NodeUse lookupVariable_String_value = lookupVariable_compute(name);
        return lookupVariable_String_value;
    }

    private NodeUse lookupVariable_compute(String name) {
		if (name.equals("this")) {
			return getNodeUse(); 
		}
		return null;
	
	}

    // Declared in PrettyPrint.jrag at line 30
    public String Define_String_indent(ASTNode caller, ASTNode child) {
        if(caller == getAltRecoverListNoTransform()) {
      int index = caller.getIndexOfChild(child);
            return indent() + "  ";
        }
        return getParent().Define_String_indent(this, caller);
    }

    // Declared in NameAnalysis.jrag at line 205
    public NodeUse Define_NodeUse_lookupVariable(ASTNode caller, ASTNode child, String name) {
        if(caller == getAltRecoverListNoTransform()) { 
   int index = caller.getIndexOfChild(child);
{
		AltRecover alt = getAltRecover(index);
		if (alt.isRecover()) {
			SitePattern pattern = ((Recover)alt).getSitePattern();
			for (int i = 0; i < pattern.getNumSiteNodeUse(); i++) {
				SiteNodeUse use = pattern.getSiteNodeUse(i);
				if (use.getVarName().equals(name)) {
					return use;
				}
			}
		}
		return lookupVariable(name);
	}
}
        return getParent().Define_NodeUse_lookupVariable(this, caller, name);
    }

public ASTNode rewriteTo() {
    return super.rewriteTo();
}

}
